import RPi.GPIO as GPIO from RPIO import PWM import picamera import time orders = raw_input('Use WASD to control camera. "c" to center,"o" to quit.') camera = picamera.PiCamera() GPIO.setmode(GPIO.BCM) GPIO.setup(4, GPIO.OUT) GPIO.setup(17, GPIO.OUT) servox = PWM.Servo() servoy = PWM.Servo() xlocation = 1420 ylocation = 1290 servox.set_servo(4, xlocation) servoy.set_servo(17, ylocation) camera.start_preview() while True and orders != 'q': if orders == 'w' and not ylocation > 1490: ylocation = ylocation + 100 servoy.set_servo(17, ylocation) elif orders == 's' and not ylocation < 400: ylocation = ylocation - 100 servoy.set_servo(17, ylocation) elif orders == 'a' and not xlocation > 1820: xlocation = xlocation + 100 servox.set_servo(4, xlocation) elif orders == 'd' and not xlocation < 1020: xlocation = xlocation - 100 servox.set_servo(4, xlocation) elif orders == 'c': xlocation = 1420 ylocation = 1290 servox.set_servo(4, xlocation) servoy.set_servo(17, ylocation) elif orders == '1': camera.stop_preview() elif orders == '2': camera.start_preview() orders = raw_input() xlocation = 1420 ylocation = 1290 servox.set_servo(4, xlocation) servoy.set_servo(17, ylocation) camera.stop_preview GPIO.output(4,0) GIPO.output(17,0) camera.close GPIO.cleanup()